﻿/*----------------------------------------------------------------
 * 
 * 版权所有：Copyright (C) 2013
 * 
 * 文件名：ProductConfiguration.cs
 * 文件功能描述：
 * 
 * 
 * 作 者：zhangq
 * 邮 箱：ifunnyface@outlook.com
 * 日 期：2013-02-04 09:26:49
 * 
 * 
 * 修改标识： Author
 * 修改描述： 相关描述
 * 
 * ---------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using DomainModel;

namespace Infrastructure.Mapper
{

    /// <summary>
    /// 
    /// </summary>
    public class ProductConfiguration : EntityTypeConfiguration<ProductInfo>
    {

        /// <summary>
        /// 
        /// </summary>
        public ProductConfiguration()
        {
            ToTable("CTB_Products");
            HasKey(u => u.Id).Property(u => u.Id);

            Property(u => u.Image).HasMaxLength(100);
            Property(u => u.Description).HasMaxLength(2000);
            Property(u => u.ProductName).HasMaxLength(200);
            Property(u => u.Price).HasColumnType("float");
            Property(u => u.PriceUnit);
            Property(u => u.Model).HasMaxLength(50);
            Property(u => u.Manufacturers).HasMaxLength(200);
            Property(u => u.IsChecked);
            Property(u => u.KeyWords).HasMaxLength(200);
            Property(u => u.AddDate);
            Property(u => u.AddUserID);
            Property(u => u.AddUserName).HasMaxLength(50);
            Property(u => u.LastModifiled);
            
            HasRequired(t => t.Company)
                .WithMany(t => t.Products)
                .HasForeignKey(d => d.CompanyId);


            HasRequired(t => t.Partition)
                .WithMany(t => t.Products)
                .HasForeignKey(d => d.PartitionId);
        }

         
    }

}